<template>
<h2>登录</h2>
<table border="1">
    <tr>
        <td>用户名</td>
        <td>
            <input type="text" v-model="MemberName">
        </td>
    </tr>
    <tr>
        <td>密码</td>
        <td>
            <input type="password" v-model="Pwd">
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="button" value="登录" @click="SaveData">
        </td>
    </tr>
</table>
</template>
<script setup lang="ts">
import { onMounted ,ref} from "vue";
import { useRouter } from "vue-router";
import axios from 'axios';
import{useCounterStore}from '../stores/counter.ts'

const MemberName=ref("");
const Pwd=ref("");
const router= useRouter();

const Counters=useCounterStore();

const SaveData=()=>{
    axios.get('https://localhost:7133/api/KeiShi/LoginInfo',
    {
        params:{
            MemberName:MemberName.value,
            Pwd:Pwd.value
        }
    }
    )
    .then(res=>{
        if(res.data.MemberId>0){
            alert("登录成功");
            Counters.MemberName=res.data.MemberName
            console.log(Counters.MemberName);
            router.push("/AddKeiShi")
            
        }
        else{
            alert("登录失败");
        }
    })


}

</script>